package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ArrayToListDemo {
    public static void main(String[] args) {
        String[]array={"a","b","c","d"};
        System.out.println("array"+ Arrays.toString(array));
        List<String>list=Arrays.asList(array);
        System.out.println("list:"+list);
        //对集合操作就是对原数组的操作
        list.set(0,"A");
        System.out.println("list:"+list);
        System.out.println("array:"+Arrays.toString(array));
        //由于数组是定长的，任何改变数组个数的操作都会异常
        //list.add("f");//报错

        List<String>list2=new ArrayList<>(list);
        list2.add("f");
        System.out.println("list2:"+list2);
    }
}
